package com.erlang4j.api;

import com.erlang4j.api.exceptionHandler.IExceptionHandler;
import com.erlang4j.api.exceptionHandler.SysoutExceptionHandler;
import com.erlang4j.internal.Erlang4J;

/**
 * Using Erlang4J, this is the main point of access to Erlang from java. There are some ideas that you need to
 * understand before you use.
 * 
 *<ul>
 *<li>Each {@link IErlang4j} represents a link to a single Erlang node or virtual machine. You need to know the name
 * and cookie of this node
 * <li>JInterface which is the underlying communication will create a new Erlang node for each Java JVM that is linking
 * to Erlang. This needs a name. The default name is JavaVm. Obviously if you want multiple java clients connected you
 * will need to give them unique names
 * <li>The exception handler is called when there is an exception. The default writes to System.out, which is useful
 * while debugging. In a production system you will want to write your own to link to an event logger
 * <ul>
 * </p>
 * 
 * Design notes
 * <ul>
 * <li>This is mostly to ease any future dependancy injections: it is much easier to return wrapped {@link IErlang4j}s,
 * is they are all created here
 * </ul>
 * */
public class Erlang4jFactory {

	public static IErlang4j make(String erlangVm, String cookie) {
		return new Erlang4J(erlangVm, cookie, "JavaVm", new SysoutExceptionHandler());
	}

	public static IErlang4j make(String erlangVm, String cookie, String javaVm) {
		return new Erlang4J(erlangVm, cookie, javaVm, new SysoutExceptionHandler());
	}

	public static IErlang4j make(String erlangVm, String cookie, IExceptionHandler exceptionHandler) {
		return new Erlang4J(erlangVm, cookie, "JavaVm", exceptionHandler);
	}

	public static IErlang4j make(String erlangVm, String cookie, String javaVm, IExceptionHandler exceptionHandler) {
		return new Erlang4J(erlangVm, cookie, javaVm, exceptionHandler);
	}

}
